package com.example.myapplication.Room;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;

import com.example.myapplication.R;
import com.example.myapplication.Room.room.Student;
import com.example.myapplication.Room.room.manager.DBEngine;

public class RoomSQLIstActivity extends AppCompatActivity {

    private DBEngine dbEngine;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_room_sqlist);
        dbEngine = new DBEngine(this);
    }

    public void insertAction(View view) {
        Student student1 = new Student("大哥",20);
        Student student2 = new Student("二哥",32);
        Student student3 = new Student("三哥",43);
        dbEngine.insertStudents(student1,student2,student3);
    }

    public void deleteAction(View view) {
        Student student = new Student(null,0);
        student.setId(3);
        dbEngine.deleteStudents(student);
    }

    public void deleteAllAction(View view) {
        dbEngine.deleteAllStudents();
    }

    public void upDateAction(View view) {
        Student student = new Student("ccc",33);
        student.setId(2);
        dbEngine.updateStudents(student);
    }

    public void getAllAction(View view) {
        dbEngine.getAllStudents();
    }
}